<%
	local uci = require 'luci.model.uci'.cursor()
	ssl = uci:get_first('alist', 'alist', 'ssl')
	if ssl == '1' then
		protocol="https://"
	else
		protocol="http://"
	end
%>

<script type="text/javascript">//<![CDATA[
	XHR.poll(5, '<%=luci.dispatcher.build_url("admin/services/alist_status")%>', null,
		function(x, st)
		{
			var tb = document.getElementById('alist_status');
			if (st && tb)
			{
				if (st.running)
				{
					tb.innerHTML = '<em style=\"color:green\"><b><%:The Alist service is running.%></b></em>' + "<input class=\"cbi-button-reload mar-10\" type=\"button\" value=\" <%:Click to open Alist%> \" onclick=\"window.open('<%=protocol%>" + window.location.hostname + ":" + st.port + "/')\"/>" +  '当前Alist管理密码:  ' + st.rpassword;
				}
				else
				{
					tb.innerHTML = '<em style=\"color:red\"><b><%:The Alist service is not running.%></b></em>';
				}
			}
		}
	);
//]]></script>

<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
	<p id="alist_status">
		<em><b><%:Collecting data...%></b></em>
	</p>
</fieldset>
